import requests
import json

def coup(up):
    header = {
    'Accept': '*/*',
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Connection': 'keep-alive',
    'Host': 'ai-backend.binwang.me',
    'Origin': 'https://ai.binwang.me',
    'Referer': 'https://ai.binwang.me/couplet/',
    "User-Agent": r"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.64 Safari/537.36"
    }


    url = "https://ai-backend.binwang.me/chat/couplet/"+up

    html = requests.get(url=url, headers=header)
    content = html.content

    content = json.loads(content)
    content = content['output']
    # print(json.dumps({
    #     "上联": up,
    #     "下联": content
    # }, ensure_ascii=False))
    # print("上联：{}\n下联：{}".format(up, content))
    return content